'''
class Box:
    def __init__(self, items):
        self.items = items

    def make_a_pile_to_look_through(self):
        return [self]

    def grab_a_box(self):
        return self

    def is_a_box(self):
        return True

    def is_a_key(self):
        return False


def look_for_key(main_box):
    pile = main_box.make_a_pile_to_look_through()
    while pile:
        box = pile.pop()
        for item in box.items:
            if isinstance(item, Box):
                pile.append(item)
            elif item.is_a_key():
                print("found the key!")


# 示例调用
box1 = Box([Box([]), Box([])])
look_for_key(box1)
'''

def look_for_key(box):
    for item in box:
        if item.is_a_box():
            look_for_key(item)
        elif item.is_a_key():
            print ("found the key!")